const oracledb = require('oracledb');
const config = require('./local.secret').oss30Config;

//{ outFormat: oracledb.OUT_FORMAT_OBJECT }
module.exports = async function genTableColumnsMeta(tableName) {
  const connection = await oracledb.getConnection(config);
  const sql = `select column_name,data_type,data_length from all_tab_cols 
      where owner = SYS_CONTEXT('USERENV','CURRENT_USER') and table_name=:tab`;
  const result = await connection.execute(sql, [tableName.toUpperCase()], {outFormat: oracledb.OUT_FORMAT_OBJECT});
  await connection.close().catch(console.error);
  return result.rows
};